package com.crop.back.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.crop.back.entity.Feedback;
import com.crop.back.mapper.FeedbackMapper;
import com.crop.back.service.FeedbackService;
import org.springframework.stereotype.Service;

@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback> implements FeedbackService {
    
    @Override
    public Page<Feedback> getFeedbackList(String contactType, String contactInfo, Integer page, Integer size) {
        return this.page(new Page<>(page, size),
            new LambdaQueryWrapper<Feedback>()
                .eq(contactType != null, Feedback::getContactType, contactType)
                .like(contactInfo != null, Feedback::getContactInfo, contactInfo)
                .orderByDesc(Feedback::getId)
        );
    }
}
